package com.jtjrenren.android.taxi.driver.core.order.finish;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jtjrenren.android.taxi.driver.Constants;
import com.jtjrenren.android.taxi.driver.bean.Order;
import com.jtjrenren.android.taxi.driver.R;
import com.jtjrenren.android.taxi.driver.base.BaseActivity;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by Administrator on 2016/5/11.
 */
public class OrderFinishActivity extends BaseActivity {
    @BindView(R.id.title_title)
    TextView title;
    @BindView(R.id.orderpay_start)
    TextView tv_start;
    @BindView(R.id.orderpay_end)
    TextView tv_end;
    @BindView(R.id.orderpay_total)
    TextView tv_total;
    @BindView(R.id.orderpay_desc)
    TextView tv_desc;
    @BindView(R.id.orderpay_time)
    TextView tv_time;
    @BindView(R.id.orderpay_fh)
    Button bt_fh;
    @BindView(R.id.orderfinish_payresult)
    LinearLayout ll_ordrepayresult;
    @BindView(R.id.orderfinsih_cancle)
    TextView tv_cancle;

    private Order order;

    public static Intent getDiyIntent(Context context,Order order){
        Intent intent=new Intent(context,OrderFinishActivity.class);
        intent.putExtra("order",order);
        return intent;
    }

    @Override
    public int getLayoutID() {
        return R.layout.aty_order_finish;
    }

    @Override
    public void init() {
        if (getIntent().hasExtra("order"))
            order = (Order) getIntent().getExtras().get("order");

        ((TextView) findViewById(R.id.title_title)).setText("订单详情");
        findViewById(R.id.title_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });

        refreshView();
    }

    @OnClick(R.id.orderpay_fh)
    public void fh(){
        onBackPressed();
    }

    private void refreshView() {
        if (order == null)
            return;

        tv_start.setText(order.getStartAddr());
        tv_end.setText(order.getEndAddr());
        tv_time.setText(order.getCreateDate());

        if (order.getOrderStatus() == Constants.STATUS_ORDER_CANCLE) {
            tv_cancle.setVisibility(View.VISIBLE);
        } else {
            ll_ordrepayresult.setVisibility(View.VISIBLE);
            tv_total.setText(order.getTotal() + "");
            String stausDesc = "已支付";
            if (order.getPayStatus() != 1)
                stausDesc = "未支付";
            tv_desc.setText(stausDesc);
        }
    }

}
